home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
simula
/
books
/
books.lha
/
kirkerud
/
countld.sim
< prev
next >
Wrap
Text File
|
1993-08-16
|
771b
|
30 lines
! Proposed solution to exercise 3.5: "Count letters and digits";
begin
integer number_of_digits, number_of_letters;
character char_typed;
outtext("Type some characters. Quit with an exclamation mark!"); outimage;
inimage;
char_typed := inchar;
while char_typed ne '!' do
begin
if digit(char_typed) then
number_of_digits := number_of_digits + 1 else
if letter(char_typed) then
number_of_letters := number_of_letters + 1;
char_typed := inchar;
end;
outtext("You typed ");
outint(number_of_letters, 0);
outtext(" letter"); if number_of_letters ne 1 then outchar('s');
outtext(" and ");
outint(number_of_digits, 0);
outtext(" digit"); if number_of_digits ne 1 then outchar('s');
outimage;
end